package cpr.controller;

import java.rmi.*;

import rmi.CasaCentralInterfaz;

public class ClienteCprRMI {

	private static ClienteCprRMI instancia;
	private CasaCentralInterfaz iRemota;
	
	public ClienteCprRMI () {		
	}
	
	public static ClienteCprRMI getInstance()
	{
		if (instancia == null)
			instancia = new ClienteCprRMI();
		return instancia;	
	}

	public boolean getStub() {
    	System.setProperty("java.security.policy", "java.policy");
    	boolean ok = false;
    	try {
    		System.setSecurityManager(new RMISecurityManager());
			iRemota = (CasaCentralInterfaz)Naming.lookup ("//localhost/CprRemoto");
			System.out.println("Conectado con servicio remoto.");
			ok = true;
		} catch (Exception e) {
			System.out.println("No se pudo conectar con servicio remoto." + "\n" + e.getMessage());
		}
		return ok;
    }

	public CasaCentralInterfaz getIRemota() {
		return iRemota;
	}
	
	
}

